package cn.cvs.service;

import cn.cvs.dao.FruitMapper;
import cn.cvs.pojo.Fruit;
import cn.cvs.utils.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class FruitService {
    SqlSession sqlSession = MybatisUtil.createSqlSession();
    FruitMapper mapper = sqlSession.getMapper(FruitMapper.class);
    public List<Fruit> list(){
        return mapper.list();
    }
    public Fruit detail(Integer id){
        return mapper.detail(id);
    }
    public int delete(int id){
        int count =0;
        count = mapper.delete(id);
        if (count>0){
            sqlSession.commit();
        }else{
            sqlSession.rollback();
        }
        return count;
    }
}
